package chain.example.delivery.decorate;

import java.util.ArrayList;
import java.util.List;

public class RealDeliveryInfo implements StateInfo {

    private StateInfo stateInfo;

    public RealDeliveryInfo(StateInfo stateInfo) {
        this.stateInfo = stateInfo;
    }

    /**
     * 实际去查询数据库，然后获取到对应对象的信息
     *
     * @param orderId
     * @return
     */
    @Override
    public List<String> getMessage(String orderId) {
        return selectDeliveryInfoByOrderId(orderId);
    }

    /**
     * 通过数据库查询到订单的配送信息数据
     * @param orderId
     * @return
     */
    private List<String> selectDeliveryInfoByOrderId(String orderId) {
        List<String> info = new ArrayList<>();
        info.addAll(stateInfo.getMessage(orderId));

        info.add("商品已从深圳出发");
        info.add("到达武汉");
        info.add("正在派件");
        info.add("已签收");

        return info;
    }


}
